import React from 'react'
import { SimpleSelector } from './simpleSelector'
import { SuiteLevel } from '../../common/enums'

export const SuiteLevelSelector = ({ showNoLimitItem, initValue, onSelectItem, placeholder = 'Suite级别', readOnly = false }) => {
    const dataSource = (showNoLimitItem ? [{ code: '', title: '[不限Level]' }] : [])
        .concat(Object.keys(SuiteLevel).map(level => ({ code: level, title: level })).filter(Boolean))
    const filterDataSource = React.useCallback(value => item => item.code.includes(value) || item.title.includes(value), [])
    const getItemValue = React.useCallback(item => item.code, [])
    const renderItem = React.useCallback(item => item.title, [])

    return <SimpleSelector dataSource={dataSource} filterDataSource={filterDataSource}
        getItemValue={getItemValue} initValue={initValue} onSelectItem={onSelectItem}
        readOnly={readOnly} renderItem={renderItem} placeholder={placeholder}
        inputClassName='width_85px' />
}